import { Page, PageItemSearch, PageRowStatus, ResPageList, TreeType } from '../../../common/types/page';

export type MenuId = number;

export type MenuSelect = { menu_id: Array<MenuId>; menu_action_id: Array<MenuId> };

export type MenuInfo = {
  menu_id: MenuId;
  parent_id: number;
  menu_name: string;
  router: string;
  /**1本地应用  2微应用 3、新打开链接 */
  path: string;
  router_type: 1 | 2 | 3; //1本地应用  2微应用 3、新打开链接
  /**1顶部主菜单  2左侧菜单 3、功能 */
  menu_type: 1 | 2 | 3; //1顶部主菜单  2左侧菜单 3、功能
  menu_order: number;
  icon: string;
  menu_desc?: string;
} & PageRowStatus;

/**
 * 编辑菜单参数
 */
export type MenuParam = Pick<MenuInfo, 'menu_name' | 'path' | 'router_type' | 'router' | 'menu_type' | 'menu_order' | 'icon' | 'menu_desc' | 'parent_id'>;

/**
 * 请求菜单类型
 */
export type ReqMenuParam = MenuParam;

/**
 * 响应菜单数据
 */
export type ResMenu = { menu_action_list: Array<MenuInfo>; menu_list: Array<MenuInfo> };
/**
 * 树形菜单
 */
export type MenuTreeType = Array<TreeType & Partial<MenuInfo>>;
/**
 * 响应菜单查询
 */
export type ResMenuSearch = Array<PageItemSearch>;
/**
 * 角色显示
 */
export type ResShowMenu = MenuInfo;

/**
 * 冻结解冻
 */
export type MenuStatus = {
  menu_id: Number; //用户id
  /** 1 正常 2、停用（冻结）*/
  status: 1 | 2; //状态1 正常 2、停用（冻结）
};
/**
 * 添加角色
 */
export type AddMenuParam = MenuParam;
/**
 * 修改角色
 */
export type UpdateMenuParam = MenuParam & { menu_id: MenuId };

export enum MenuRouterType {
  'Location' = 1,
  'Micro' = 2,
  'New' = 3
}
